<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>重置密码</title>
    <#include "admin/common/header.ftl"/>
<body>
<div class="container-fixed-xs" style="background: url("../static/images/big.jpg") no-repeat;">
    <div style="margin-left: 20px; margin-right: 20px; padding-top: 100px; padding-bottom: 100px;">
        <center><h2>重置密码</h2></center>
        <form id="resetForm" method="post" action="/updatePwd">
            <input type="hidden" id="id" name="id" value="${id }">
            <div class="form-group">
                <label for="email" class="required">原始密码</label>
                <input type="password" class="form-control" id="passWord" name="passWord" placeholder="请输入原始密码">
            </div>
            <div class="form-group">
                <label for="email" class="required">新密码</label>
                <input type="password" class="form-control" id="newPassWord" name="newPassWord" placeholder="请输入新密码">
            </div>
            <div class="form-group">
                <label for="email" class="required">重复密码</label>
                <input type="password" class="form-control" id="rNewPassWord" name="rNewPassWord" placeholder="请再次输入新密码">
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-large btn-block btn-primary">重置密码</button>
                <button type="button" class="btn btn-large btn-block btn-primary" id="resetBtn">取消</button>
            </div>
        </form>
    </div>
</div>
<script>
    $(document).ready(function() {
        $('#resetForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                passWord: {
                    message: '原始密码验证失败',
                    validators: {
                        notEmpty: {
                            message: '原始密码不能为空'
                        }
                    }
                },
                newPassWord: {
                    message: '新密码验证失败',
                    validators: {
                        notEmpty: {
                            message: '新密码不能为空'
                        },
                        identical: {
                            field: 'newPassWord',
                            message: '两次密码不一致'
                        },
                    }
                },
                rNewPassWord: {
                    message: '重复密码验证失败',
                    validators: {
                        notEmpty: {
                            message: '重复密码不能为空'
                        },
                        identical: {
                            field: 'newPassWord',
                            message: '两次密码不一致'
                        }
                    }
                }
            }
        }).on('success.form.bv',function (e) {
            // Prevent form submission
           e.preventDefault();

           // Get the form instance
           var $form = $(e.target);

           // Get the BootstrapValidator instance
           var bv = $form.data('bootstrapValidator');

           // Use Ajax to submit form data
           $.post($form.attr('action'), $form.serialize(), function(result) {
                 console.log(result);
                 if (result.errorCode == 'y') {
                     new $.zui.Messager('提示消息：' + result.errorText, {
                         icon: 'exclamation-sign',
                         type: 'success',
                         time: 2000
                     }).show();
                     window.location.href = "/";
                 } else {
                     new $.zui.Messager('提示消息：' + result.errorText, {
                         icon: 'exclamation-sign',
                         type: 'danger',
                         time: 2000
                     }).show();
                 }
           }, 'json');
        });
        $('#resetBtn').click(function() {
            $('#resetForm').data('bootstrapValidator').resetForm(true);
        });
    });
</script>
<style>
    body {
        background-color: #F0F0F0;
        background-attachment:fixed;
        background-size:100%;
        height:auto;
    }
</style>
</body>
</html>